<?php
        header('Content-Type: application/json');
        $params = json_decode(file_get_contents('php://input'));
		$colReq2 = $params->colReq2;
		$user = $params->user;
		
		
		
        $m = new Mongo();
        $db = $m->EMU;
        $collection = $db->$colReq2;
        $cursor = $collection->find(array( '$and' => array( array('location'=> $user), array('status'=> array('$ne' => "closed")))));
		
		//$cursor = $collection->find();
        $m->close();
	 

   	$data = array('messages' => array());
 	foreach($cursor as $message)
	{
		array_push($data['messages'], $message);

	}

       $response = array(
                "data" => $data
        );

        $json_string = json_encode($response);
        echo $json_string;
?>